CXX := g++  
CXXFLAGS := -std=c++11 -Wall -Wextra  
  
SRCS := NewtonPoly.cpp ProblemA.cpp ProblemB.cpp ProblemC.cpp ProblemD.cpp ProblemE.cpp  
OBJS := $(SRCS:.cpp=.o)  
  
TARGETS := AnswerB AnswerC AnswerD AnswerE report_HW2.pdf
  
.PHONY: all clean  
  
PROJ = report_HW2
IMAGE = imgs

all: $(TARGETS)  
  
AnswerB: ProblemB.o ProblemA.o NewtonPoly.o  
	$(CXX) $(CXXFLAGS) $^ -o $@  
  
AnswerC: ProblemC.o ProblemA.o NewtonPoly.o  
	$(CXX) $(CXXFLAGS) $^ -o $@  
  
AnswerD: ProblemD.o NewtonPoly.o  
	$(CXX) $(CXXFLAGS) $^ -o $@  
  
AnswerE: ProblemE.o NewtonPoly.o  
	$(CXX) $(CXXFLAGS) $^ -o $@  
  
%.o: %.cpp  
	$(CXX) $(CXXFLAGS) -c $< -o $@  
  
ProblemA.o: ProblemA.cpp ProblemA.h NewtonPoly.h  
	$(CXX) $(CXXFLAGS) -c ProblemA.cpp -o ProblemA.o  
  
NewtonPoly.o: NewtonPoly.cpp NewtonPoly.h  
	$(CXX) $(CXXFLAGS) -c NewtonPoly.cpp -o NewtonPoly.o  

run:
	./AnswerB
	./AnswerC
	./AnswerD
	./AnswerE

$(PROJ).pdf : $(PROJ).tex $(IMAGE)
	xelatex $(PROJ)
	xelatex $(PROJ)
  
clean:  
	rm -f $(OBJS) $(TARGETS) \
	*.aux *.log *.out *.bbl \
	*.blg *.bcf *.xml *.gz